package at.ac.thornwishstalon.ocrapp.pic;

import java.util.HashMap;

import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;

public class PaintBucket {
	private static PaintBucket instance=null;
	private HashMap<Integer, Paint> paints;
	
	private PaintBucket(){
		paints= new HashMap<Integer, Paint>();
		
		Paint	rectPaint= new Paint();
		rectPaint.setColor(Color.WHITE);
		rectPaint.setStrokeWidth(7);
		rectPaint.setStyle(Style.STROKE);
		rectPaint.setAlpha(100);
		paints.put(Color.WHITE, rectPaint);

		Paint bbPaint= new Paint();
		bbPaint.setColor(Color.BLUE);
		bbPaint.setStrokeWidth(3);
		bbPaint.setStyle(Style.STROKE);
		bbPaint.setAlpha(100);
		paints.put(Color.BLUE, bbPaint);
		
		Paint linePaint= new Paint();
		linePaint.setColor(Color.RED);
		linePaint.setStrokeWidth(3);
		linePaint.setStyle(Style.STROKE);
		linePaint.setAlpha(100);
		paints.put(Color.RED, linePaint);

		Paint regionPaint= new Paint();
		regionPaint.setColor(Color.GREEN);
		//regionPaint.setStrokeWidth(3);
		regionPaint.setStyle(Style.FILL);
		regionPaint.setAlpha(50);
		paints.put(Color.GREEN, regionPaint);
		
		Paint background= new Paint();
		background.setColor(Color.BLACK);
		//regionPaint.setStrokeWidth(3);
		background.setStyle(Style.FILL);
		background.setAlpha(100);
		paints.put(Color.BLACK, background);
	}
	
	public static PaintBucket getInstance(){
		if(instance==null)
			instance= new PaintBucket();
		return instance;
	}
	
	public Paint get(int color, Paint.Style style, int alpha){
		Paint paint=paints.get(color);
		
		if(paint==null){
			paint = new Paint();
			paint.setColor(color);
			paint.setStyle(style);
			if(alpha != -1)
				paint.setAlpha(alpha);
			paints.put(color, paint);
		}
		else{
			paint.setStyle(style);
			paint.setStyle(style);
			if(alpha != -1)
				paint.setAlpha(alpha);
		}
		return paint;
	}
	
	

}
